<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets"
	template="/sistema/template/template.xhtml" xmlns:p="http://primefaces.org/ui">

	<ui:param name="titulo" value="#{label.manutencao_perfis_titulo}" />

	<ui:define name="corpo">

		<h:form id="FORM_PRINCIPAL">

			<h:panelGrid id="PANEL_GRID_PRINCIPAL">

				<h:panelGrid columns="2" id="PANEL_GRID_INTERNO_1">
					
					<p:column>
						<p:outputLabel id="NOME_LBL" value="#{label.manutencao_perfis_nome}" for="NOME" />
						<br />
						<p:inputText id="NOME" value="#{perfilMB.model.nome}" label="#{label.manutencao_perfis_nome}"
							required="#{perfilMB.editando}" />
					</p:column>
					
				</h:panelGrid>

				<p:column>
					<p:outputLabel id="DESCRICAO_LBL" value="#{label.manutencao_perfis_descricao}" for="DESCRICAO" />
					<br />
					<p:inputTextarea id="DESCRICAO" value="#{perfilMB.model.descricao}" label="#{label.manutencao_perfis_descricao}"
						maxlength="100" cols="52" />
				</p:column>

				<h:panelGrid columns="2"  id="PANEL_GRID_INTERNO_2">
					<p:outputLabel id="STAUTS_LBL" value="#{label.manutencao_perfis_status}" for="STAUTS" />
					<p:selectOneRadio id="STAUTS" value="#{perfilMB.model.status}" required="#{perfilMB.editando}"
						label="#{label.manutencao_perfis_status}">
						<f:selectItems value="#{perfilMB.status}" />
					</p:selectOneRadio>
				</h:panelGrid>

				<p:spacer height="20" />

				<p:column>
					<p:commandButton value="#{label.sistema_pesquisar}" rendered="#{!perfilMB.editando}"
						actionListener="#{perfilMB.pesquisar}" update="DATA_TABLE_MODEL" />

					<p:commandButton value="#{label.sistema_salvar}" rendered="#{perfilMB.editando}" update="@form"
						actionListener="#{perfilMB.salvar}" icon="ui-icon-disk" />

					<p:commandButton value="#{label.sistema_cancelar}" rendered="#{perfilMB.editando}"
						actionListener="#{perfilMB.cancelar}" immediate="true" update="@form" />
				</p:column>

			</h:panelGrid>

			<p:spacer height="20" />

			<h:panelGrid  id="PANEL_GRID_INTERNO_3">
				
				<p:dataTable id="DATA_TABLE_MODEL" value="#{perfilMB.modelList}" var="item" rendered="#{!perfilMB.editando}"
					style="width:600px;">

					<p:column headerText="#{label.manutencao_perfis_nome}">
						<p:outputLabel value="#{item.nome}" />
					</p:column>

					<p:column headerText="#{label.manutencao_perfis_status}">
						<p:outputLabel value="#{item.status}" />
					</p:column>

					<p:column headerText="#{label.sistema_acoes}">
						<p:commandButton id="EDIT_MODEL" icon="ui-icon-pencil" action="#{perfilMB.editar}" update="@form">
							<f:setPropertyActionListener value="#{item.codigo}" target="#{perfilMB.model.codigo}" />
						</p:commandButton>
						
						<p:commandButton icon="ui-icon-trash" onclick="modalExcluir.show();">
							<f:setPropertyActionListener target="#{perfilMB.model.codigo}" value="#{item.codigo}" />
						</p:commandButton>
					</p:column>

				</p:dataTable>
				
			</h:panelGrid>

			<p:spacer height="40" />
			
			<p:column>
				<p:commandButton value="#{label.sistema_novo}" rendered="#{!perfilMB.editando}"
					actionListener="#{perfilMB.novoItem}" immediate="true" update="@form" />
			</p:column>

			<ui:include src="/sistema/componentes/popupExcluir.xhtml">
				<ui:param name="MB" value="#{perfilMB}" />
			</ui:include>
			
		</h:form>

	</ui:define>

</ui:composition>
